package lib.quasar.widget.paint;

import android.graphics.Color;
import android.graphics.Paint;

import lib.quasar.util.DimenUtil;

public final class PaintManager {

    private final static Paint mPaint = new Paint();
    public static float LiNE_WIDTH = DimenUtil.dp2px(1.5f);
    public static float LiNE_ARROW = DimenUtil.dp2px(2f);
    public static float DASH_WIDTH = DimenUtil.dp2px(0.8f);
    public static float TEXT_AXIS_SIZE = DimenUtil.sp2px(8.5f);
    public static float TEXT_UNIT_SIZE = DimenUtil.sp2px(12.2f);
    public static float TEXT_HINT_SIZE = DimenUtil.sp2px(13.2f);
    public static float DOT_RADIUS = DimenUtil.dp2px(2.5f);

    public static final int RED = Color.parseColor("#ea5757");
    public static final int WHITE = Color.WHITE;
    public static final int GREEN = Color.parseColor("#13ad67");
    public static final int ORANGE = Color.parseColor("#ff9e21");
    public static final int BLUE = Color.parseColor("#1296db");
    public static final int BLACK = Color.BLACK;

    public static Paint getTextPaint(int color, float textsize) {
        return getTextPaint(color, textsize, false);
    }

    public static Paint getTextPaint(int color) {
        return getTextPaint(color, 0f, false);
    }

    public static Paint getTextPaint(int color, float textsize, boolean bold) {

        mPaint.clearShadowLayer();
        mPaint.reset();
        mPaint.setAntiAlias(true);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setFakeBoldText(bold);
        mPaint.setColor(color);
        mPaint.setTextSize(textsize);
        mPaint.setTextAlign(Paint.Align.CENTER);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);

        return mPaint;
    }

    public static Paint getLinePaint(int color, float width) {

        return getLinePaint(color, width, false);
    }

    public static Paint getLinePaint(int color, float width, boolean fill) {

        mPaint.clearShadowLayer();
        mPaint.reset();
        mPaint.setAntiAlias(true);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setFakeBoldText(true);
        mPaint.setColor(color);
        mPaint.setStrokeWidth(width);
        mPaint.setTextSize(0f);
        mPaint.setTextAlign(Paint.Align.CENTER);
        mPaint.setStyle(fill ? Paint.Style.FILL_AND_STROKE : Paint.Style.STROKE);

        return mPaint;
    }
}
